﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Globalization;


namespace Misc
{
    public class misc
    {
        public static bool _TryToDouble(string s, out double d)
        {
            d = 0;
            bool res = false;
            if (s.Trim() != "")
            {
                string _s;
                if (s.IndexOf(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator)!=-1)
                    _s = s.Replace(" ", "");
                else
                {
                    if (CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator == ".")
                        _s = s.Replace(" ", "").Replace(",",".");
                    else
                        _s = s.Replace(" ", "").Replace(".",",");
                }
                res = double.TryParse(_s, NumberStyles.Any /*Number*/, CultureInfo.CurrentCulture, out d);
            }
            else res = true;
            return res;
        }
    }
}
